package ru.spb.nicetu.schoolproject;

import ru.spb.nicetu.schoolproject.data.HibernateTblModel;
import ru.spb.nicetu.schoolproject.data.SchoolClass;

/**
 * Created by dchernyshov on 01.04.15.
 */
public class TblModelForClasses extends HibernateTblModel<SchoolClass> {
    public TblModelForClasses() {
        super(SchoolClass.class, 2);
    }

    @Override
    public String getColumnName(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return "№ класса";
            case 1:
                return "Классный руководитель";
            case 2:
                return "Код выпуска";
        }
        return "";
    }

    @Override
    public int getColumnCount() {
        return 3;
    }

    @Override
    public Object getValueAt(int i, int i1) {
        SchoolClass t = list.get(i);
        switch (i1) {
            case 0:
                return t.getClassNum();
            case 1:
                return t.getFormMaster().getTeacherName().trim();
            case 2:
                if (t.isGraduated()) {
                    return t.getYear();
                }
                else {
                    return "";
                }
            default:
                return null;
        }
    }
}
